import axios from "axios";
import { MessageBox } from "element-ui";

// 创建axios实例
const service = axios.create({
  // axios中请求配置有baseURL选项，表示请求URL公共部分
  baseURL: "https://qw.ccpluss.com/",
  // 超时
  timeout: 10000,
});

//axios请求拦截器
service.interceptors.request.use((config) => {
  // console.log(config);
  config.headers['Content-Type'] = "application/json";
  return config;
},error => {
  Promise.reject(error);
});

// 响应拦截器
service.interceptors.response.use(
  function (response) {
    return response.data;
  },
  function (error) {
    MessageBox.confirm("系统出错,请联系管理员", {
      type: "warning",
    }).then(() => {});
    return Promise.reject(error);
  }
);
export default service;
